function e(t) {
    if (t.data.second > 0) {
        var o = t.data.second - 1;
        t.setData({
            isSendEnable: !1,
            second: o,
            sendClass: "right",
            sendText: o + "秒重发",
            phoneDisable: !0,
            phoneCorrect: !0
        }), n = setTimeout(function() {
            e(t);
        }, 1e3);
    } else t.setData({
        isSendEnable: !0,
        sendText: "发送",
        sendClass: "right_active",
        second: 60,
        phoneDisable: !1,
        tipShow: "block"
    });
}

var t = getApp(), n = null;

Page({
    data: {
        isSendEnable: !1,
        second: 60,
        sendText: "发送",
        phoneDisable: !1,
        phone: "",
        code: ""
    },
    bindPhoneInput: function(e) {
        var t = e.detail.value;
        11 == t.length ? this.setData({
            isSendEnable: !0,
            sendClass: "active",
            phone: t,
            phoneCorrect: !0
        }) : this.setData({
            isSendEnable: !1,
            sendClass: "",
            phone: t,
            phoneCorrect: !1
        });
    },
    bindCodeInput: function(e) {
        var t = e.detail.value;
        this.setData({
            code: t
        });
    },
    sendCode: function(n) {
        if (this.data.isSendEnable) {
            if (!t.util.validatemobile(this.data.phone)) return void t.util.showToast("请输入正确的手机号码");
            var o = this;
            t.network.post({
                url: t.url.changePhoneSendSmsCode,
                params: {
                    phone: o.data.phone
                },
                before: function() {
                    wx.showLoading({
                        title: "正在发送"
                    });
                },
                success: function(n) {
                    1 == n.data.result ? (e(o), t.util.showToast(n.data.message)) : t.util.showToast(n.data.message);
                },
                fail: function() {
                    t.util.showToast("发送验证码失败");
                },
                complete: function() {
                    wx.hideLoading();
                }
            });
        }
    },
    clickOk: function(e) {
        var n = this.data.phone, o = this.data.code;
        if (t.util.validatemobile(n)) if (0 != o.length) if (4 == o.length) {
            var a = this;
            t.network.post({
                url: t.url.changePhone,
                params: {
                    phone: a.data.phone,
                    smsCode: a.data.code
                },
                before: function() {
                    wx.showLoading({
                        title: "修改中"
                    });
                },
                success: function(e) {
                    if (1 == e.data.result) {
                        t.util.showToast(e.data.message);
                        var n = getCurrentPages();
                        n[n.length - 2].setData({
                            needUpdate: !0
                        }), setTimeout(function() {
                            wx.navigateBack({});
                        }, 1e3);
                    }
                },
                fail: function() {
                    t.util.showToast("修改失败，请重试");
                },
                complete: function() {
                    wx.hideLoading();
                }
            });
        } else t.util.showToast("验证码错误"); else t.util.showToast("请输入验证码"); else t.util.showToast("请输入正确的手机号码");
    },
    onLoad: function(e) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
});